﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using ExtBusiness.Dictionary;

public partial class WebPubManager_DictionaryItemManager : System.Web.UI.Page
{
    private DictOperation dicOperation = new DictOperation();

    protected void Page_Load(object sender, EventArgs e)
    {
        string action = Request.QueryString["action"];
        if (action == "delete")
        {
            string rowid = Request.QueryString["rowid"];
            if (!string.IsNullOrEmpty(rowid))
            {
                string name = Request.QueryString["name"];
                string keyvalue = Request.QueryString["keyvalue"];

                dicOperation.DeleteDictItem(rowid);
            }
        }

        if (!IsPostBack)
        {
            BindData();
        }
    }
    protected void CustomGridView1_OnLoadData(object sender, EventArgs e)
    {
        BindData();
    }
    private void BindData()
    {
        DataTable dtSource = dicOperation.GetDictFromName(Request.QueryString["name"]);
        CustomGridView1.DataSource = dtSource;
        CustomGridView1.RecordCount = dtSource.Rows.Count;
        CustomGridView1.DataBind();
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        Response.Redirect("DictionaryAdd.aspx?name=" + Request.QueryString["name"] + "&action=add");
    }
    protected void btnReturn_Click(object sender, EventArgs e)
    {
        Response.Redirect("DictionaryManager.aspx");
    }
}
